package com.pan.test.socket.example01;

import com.pan.utils.PrintTime;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.Buffer;

/**
 *
 */
public class MyServer {
    public static void main(String[] args) throws IOException {

        ServerSocket serverSocket = new ServerSocket(11451);
        Socket socket = serverSocket.accept();
        InputStream inputStream = socket.getInputStream();
        byte[] buf = new byte[1024];
        int len;
        while ((len = inputStream.read(buf))!= -1){
            System.out.print(new String(buf,0,len));
        }

        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("hello client 你好(采用字节流发送)".getBytes());
        socket.shutdownOutput();



        outputStream.close();
        inputStream.close();
        socket.close();
        serverSocket.close();

    }
}
